home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Shareware / Signal for Windows 1.1.3 / Signal_Setup.exe / web / iphone / iphone.js < prev    next >
Text File  |  2008-09-12  |  40KB  |  1,857 lines

  1. /* 
  2. Copyright (c) 2007-2008 Alloysoft, LLC. All rights reserved.
  3. http://www.alloysoft.com
  4. */
  5. var http_request;
  6. var queue_request;
  7. var timerID=0;
  8. var timerQueue=0;
  9. var queueID=-1;
  10. var lastQueueEventId=0;
  11. var pendingRequests=new Array();
  12. var usePersistentConnection=true;
  13. var loggingEnabled=true;
  14. var isMobileSafari=true;
  15. var currentArtist="";
  16. var currentAlbum="";
  17. var currentTitle="";
  18. var currentRating=0;
  19. var currentVolume=0;
  20. var playingState;
  21. var playPosition=0;
  22. var playlistPosition=-1;
  23. var shuffleState=false;
  24. var repeatState=false;
  25. var speakers=new Array();
  26. var currentBrowsePath="";
  27. var currentSearchKeywords="";
  28. var currentArtURL="no_artwork.jpg";
  29. var searchInput="";
  30. var searchInputTimer;
  31. var elaspedPlayTime=0;
  32. var currentRequest="";
  33. var requestTimeout=5000;
  34. var isRequestPending=false;
  35. var isQueueRequestPending=false;
  36. var link_request;
  37. var isLinkRequestPending=false;
  38. var linkRecoveryRequests=new Array();
  39. var timeoutRequest=0;
  40. var timeoutCheckQueue=0;
  41. var timeoutPing=0;
  42. var timeoutPingResponse=0;
  43. var timeoutVerifyPingQueue=0;
  44. var linkRecoveryActive=false;
  45. var receivedPingResponse=false;
  46. var lastEventTime=new Date();
  47. var linkRecoveryStart=new Date();
  48. var currentWindowWidth=0;
  49. var showingMediaLib=false;
  50. var showingPlaylist=false;
  51. var showingSpeakers=false;
  52. var showingSearchResults=false;
  53. var showingMediaLibSearch=false;
  54. var showingMediaLibActions=false;
  55. var showingMediaLibAlphaJump=false;
  56. var showingMediaLibSearchResults=false;
  57. var showingSubControls=false;
  58. var lastMonitorTime=new Date();
  59. var itemsPerPage=35;
  60. var volumeIncrement=10;
  61. var slideSpeed=4;
  62. var mediaLibStart=0;
  63. var mediaLibLength=0;
  64. var playlistStart=0;
  65. var playlistLength=0;
  66. var showPlaylistItemOnPageLoad=false;
  67. var browseHistory=new Array();
  68. var currentActionItem="";
  69. var useMultipleSpeakers=false;
  70. var ignoreNextVolumeUpdate=false;
  71. var ignoreNextRatingUpdate=false;
  72. var navHistory=new Array();
  73. var navHash="#";
  74. var navCurrent="";
  75. BrowseHistoryEntry=function(){
  76. this.path="";
  77. this.search=false;
  78. this.start=0;
  79. };
  80. function createHTTPRequest(){
  81. var _1=null;
  82. if(window.XMLHttpRequest){
  83. _1=new XMLHttpRequest();
  84. if(_1.overrideMimeType){
  85. _1.overrideMimeType("text/xml");
  86. }
  87. }else{
  88. if(window.ActiveXObject){
  89. try{
  90. _1=new ActiveXObject("Msxml2.XMLHTTP");
  91. }
  92. catch(e){
  93. try{
  94. _1=new ActiveXObject("Microsoft.XMLHTTP");
  95. }
  96. catch(e){
  97. }
  98. }
  99. }
  100. }
  101. return _1;
  102. }
  103. function sendRequest(_2){
  104. if(linkRecoveryActive){
  105. if(linkRecoveryRequests.length>0&&_2==linkRecoveryRequests[linkRecoveryRequests.length-1]){
  106. return;
  107. }
  108. linkRecoveryRequests.push(_2);
  109. return;
  110. }
  111. if(isRequestPending){
  112. if(_2==currentRequest){
  113. return;
  114. }
  115. pendingRequests.push(_2);
  116. return;
  117. }
  118. if(http_request&&http_request.readyState!=4){
  119. http_request.abort();
  120. }
  121. http_request=createHTTPRequest();
  122. isRequestPending=true;
  123. currentRequest=_2;
  124. http_request.open("POST","/xml",true);
  125. http_request.setRequestHeader("Cache-Control","no-cache");
  126. http_request.setRequestHeader("If-Modified-Since","Wed, 15 Nov 1995 00:00:00 GMT");
  127. http_request.onreadystatechange=processResponse;
  128. http_request.send("xml="+_2);
  129. }
  130. function _cancelRequest(){
  131. if(!isRequestPending||currentRequest==""){
  132. return;
  133. }
  134. if(timeoutRequest){
  135. clearTimeout(timeoutRequest);
  136. timeoutRequest=0;
  137. }
  138. if(http_request){
  139. http_request.abort();
  140. http_request=null;
  141. }
  142. isRequestPending=false;
  143. }
  144. function createQueue(){
  145. if(timerQueue){
  146. clearInterval(timerQueue);
  147. timerQueue=0;
  148. }
  149. if(queue_request){
  150. queue_request.abort();
  151. queue_request=null;
  152. isQueueRequestPending=false;
  153. }
  154. queueID=-1;
  155. lastQueueEventId=0;
  156. queue_request=createHTTPRequest();
  157. queue_request.open("POST","/q",true);
  158. queue_request.setRequestHeader("Cache-Control","no-cache");
  159. queue_request.setRequestHeader("If-Modified-Since","Wed, 15 Nov 1995 00:00:00 GMT");
  160. queue_request.onreadystatechange=processQueueCreateResponse;
  161. queue_request.send("id=new");
  162. }
  163. function verifyQueueActive(){
  164. if(!usePersistentConnection||linkRecoveryActive||queueID<1){
  165. return;
  166. }
  167. if(!queue_request||!isQueueRequestPending){
  168. getQueuedEvents();
  169. }else{
  170. if(queue_request&&queue_request.readyState==0){
  171. isQueueRequestPending=false;
  172. getQueuedEvents();
  173. }
  174. }
  175. }
  176. function getQueuedEvents(){
  177. if(isQueueRequestPending){
  178. return;
  179. }
  180. try{
  181. if(queue_request&&queue_request.readyState!=4){
  182. queue_request.abort();
  183. queue_request=null;
  184. isQueueRequestPending=false;
  185. }
  186. }
  187. catch(e){
  188. }
  189. if(queueID==-1){
  190. createQueue();
  191. return;
  192. }
  193. queue_request=createHTTPRequest();
  194. isQueueRequestPending=true;
  195. queue_request.open("POST","/q",true);
  196. queue_request.setRequestHeader("Cache-Control","no-cache");
  197. queue_request.setRequestHeader("If-Modified-Since","Wed, 15 Nov 1995 00:00:00 GMT");
  198. queue_request.onreadystatechange=processQueueResponse;
  199. if(usePersistentConnection){
  200. queue_request.send("id="+queueID+"&lastEventId="+lastQueueEventId);
  201. }else{
  202. queue_request.send("id="+queueID);
  203. }
  204. }
  205. function processQueueCreateResponse(){
  206. try{
  207. if(queue_request.readyState!=4){
  208. return;
  209. }
  210. if(queue_request.status&&queue_request.status!=200){
  211. return;
  212. }
  213. queueID=parseInt(queue_request.responseText);
  214. lastQueueEventId=0;
  215. try{
  216. requestInitialState();
  217. }
  218. catch(e){
  219. writeLog("Error requesting initial state",e);
  220. }
  221. if(timerQueue){
  222. clearInterval(timerQueue);
  223. timerQueue=0;
  224. }
  225. if(usePersistentConnection){
  226. getQueuedEvents();
  227. timerQueue=setInterval(verifyQueueActive,5000);
  228. }else{
  229. timerQueue=setInterval(getQueuedEvents,1000);
  230. }
  231. }
  232. catch(e){
  233. return;
  234. }
  235. }
  236. function processQueueResponse(){
  237. try{
  238. if(queue_request.readyState!=4){
  239. return;
  240. }
  241. isQueueRequestPending=false;
  242. if(queue_request.status&&queue_request.status==404){
  243. lastEventTime=new Date();
  244. if(linkRecoveryActive){
  245. exitLinkRecovery();
  246. }
  247. createQueue();
  248. return;
  249. }else{
  250. if(queue_request.status&&queue_request.status!=200){
  251. return;
  252. }
  253. }
  254. if(!queue_request.status||queue_request.status!=200){
  255. return;
  256. }
  257. if(!queue_request.responseXML){
  258. return;
  259. }
  260. var _3=queue_request.responseXML.documentElement;
  261. if(!_3){
  262. return;
  263. }
  264. lastEventTime=new Date();
  265. if(linkRecoveryActive){
  266. exitLinkRecovery();
  267. }
  268. if(_3.attributes){
  269. var _4=_3.attributes.getNamedItem("lastEventId");
  270. if(_4){
  271. lastQueueEventId=parseInt(_4.nodeValue);
  272. if(lastQueueEventId==NaN){
  273. lastQueueEventId=0;
  274. }
  275. }
  276. }
  277. var _5=_3.getElementsByTagName("event");
  278. for(var i=0;i<_5.length;i++){
  279. try{
  280. onMessage(_5[i].firstChild);
  281. }
  282. catch(e){
  283. var _7="";
  284. if(_5[i]&&_5[i].firstChild&&_5[i].firstChild.tagName){
  285. _7=_5[i].firstChild.tagName;
  286. }
  287. writeLog("Error processing message "+_7,e);
  288. }
  289. }
  290. if(usePersistentConnection){
  291. getQueuedEvents();
  292. }
  293. }
  294. catch(e){
  295. isQueueRequestPending=false;
  296. writeLog("",e);
  297. return;
  298. }
  299. }
  300. function onMessage(_8){
  301. if(_8.tagName=="CurrentMediaChangedEvent"){
  302. processCurrentMediaChangedEvent(_8);
  303. }else{
  304. if(_8.tagName=="PlayingStateChangedEvent"){
  305. processPlayingStateChangedEvent(_8);
  306. }else{
  307. if(_8.tagName=="VolumeChangedEvent"){
  308. processVolumeChangedEvent(_8);
  309. }else{
  310. if(_8.tagName=="PlaylistChangedEvent"){
  311. processPlaylistChangedEvent();
  312. }else{
  313. if(_8.tagName=="PlaylistPositionChangedEvent"){
  314. processPlaylistPositionChangedEvent(_8);
  315. }else{
  316. if(_8.tagName=="PlayPositionChangedEvent"){
  317. processPlayPositionChangedEvent(_8);
  318. }else{
  319. if(_8.tagName=="ShuffleStateChangedEvent"){
  320. processShuffleStateChangedEvent(_8);
  321. }else{
  322. if(_8.tagName=="RepeatStateChangedEvent"){
  323. processRepeatStateChangedEvent(_8);
  324. }else{
  325. if(_8.tagName=="MediaLibraryChangedEvent"){
  326. processMediaLibraryChangedEvent();
  327. }else{
  328. if(_8.tagName=="SpeakerListChangedEvent"){
  329. processSpeakerListChangedEvent(_8);
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. function processCurrentMediaChangedEvent(_9){
  342. var _a="";
  343. var _b="";
  344. var _c="";
  345. var _d=0;
  346. var _e=_9.getElementsByTagName("title");
  347. if(_e.length>0){
  348. _c=getData(_e[0]);
  349. }
  350. _e=_9.getElementsByTagName("artist");
  351. if(_e.length>0){
  352. _a=getData(_e[0]);
  353. }
  354. _e=_9.getElementsByTagName("album");
  355. if(_e.length>0){
  356. _b=getData(_e[0]);
  357. }
  358. _e=_9.getElementsByTagName("rating");
  359. if(_e.length>0){
  360. _d=getDataInt(_e[0]);
  361. }
  362. if(!ignoreNextRatingUpdate){
  363. ignoreNextRatingUpdate=false;
  364. if(currentRating!=_d){
  365. currentRating=_d;
  366. onRatingChanged(_d);
  367. }
  368. }else{
  369. ignoreNextRatingUpdate=false;
  370. }
  371. if((currentArtist!=_a)||(currentAlbum!=_b)||(currentTitle!=_c)){
  372. currentArtist=_a;
  373. currentAlbum=_b;
  374. currentTitle=_c;
  375. if(document.getElementById){
  376. var _f=document.getElementById("artist");
  377. _f.innerHTML=_a;
  378. var _10=document.getElementById("album");
  379. _10.innerHTML=_b;
  380. var _11=document.getElementById("title");
  381. _11.innerHTML=_c;
  382. }else{
  383. _a.innerHTML=_a;
  384. _b.innerHTML=_b;
  385. _c.innerHTML=_c;
  386. }
  387. sendRequest("<GetAlbumArtRequest></GetAlbumArtRequest>");
  388. }
  389. }
  390. function processPlayingStateChangedEvent(xml){
  391. var _13=xml.getElementsByTagName("playingState");
  392. if(_13.length>0){
  393. var _14="<img src=\"images/ctrl_play.png\">";
  394. var _15=getData(_13[0]);
  395. if(_15=="playing"){
  396. _14="<img src=\"images/ctrl_pause.png\">";
  397. }
  398. if(document.getElementById){
  399. message=document.getElementById("ctrl_play");
  400. message.innerHTML=_14;
  401. }else{
  402. ctrl_play.innerHTML=_14;
  403. }
  404. }
  405. }
  406. function processVolumeChangedEvent(xml){
  407. if(ignoreNextVolumeUpdate){
  408. ignoreNextVolumeUpdate=false;
  409. return;
  410. }
  411. var _17=xml.getElementsByTagName("volume");
  412. if(_17.length>0){
  413. var _18=getDataInt(_17[0]);
  414. if(currentVolume!=_18&&_18!=NaN){
  415. currentVolume=_18;
  416. onVolumeChanged(_18);
  417. }
  418. }
  419. }
  420. function processPlaylistChangedEvent(){
  421. getPlaylistItems(playlistStart,itemsPerPage);
  422. }
  423. function processPlaylistPositionChangedEvent(xml){
  424. var _1a=xml.getElementsByTagName("position");
  425. if(_1a.length>0){
  426. var _1b=playlistPosition;
  427. playlistPosition=getDataInt(_1a[0]);
  428. var _1c=document.getElementById("playlist_"+_1b);
  429. if(_1c){
  430. _1c.className="";
  431. }
  432. _1c=document.getElementById("playlist_"+playlistPosition);
  433. if(_1c){
  434. _1c.className="playing";
  435. }
  436. if(!showingPlaylist){
  437. if(playlistPosition<playlistStart||playlistPosition>(playlistStart+itemsPerPage)){
  438. var _1d=parseInt(playlistPosition/itemsPerPage);
  439. getPlaylistItems(_1d*itemsPerPage,itemsPerPage);
  440. }
  441. }
  442. }
  443. }
  444. function processPlayPositionChangedEvent(xml){
  445. var _1f=xml.getElementsByTagName("position");
  446. if(_1f.length>0){
  447. playPosition=getDataInt(_1f[0]);
  448. }
  449. }
  450. function processShuffleStateChangedEvent(xml){
  451. var _21=xml.getElementsByTagName("shuffleState");
  452. if(_21.length>0){
  453. if(getData(_21[0])=="true"){
  454. shuffleState=true;
  455. }else{
  456. shuffleState=false;
  457. }
  458. }
  459. var _22=document.getElementById("shufflecontrol");
  460. if(_22){
  461. if(shuffleState){
  462. _22.style.background="url(\"images/shuffle_on.png\") center no-repeat";
  463. }else{
  464. _22.style.background="url(\"images/shuffle_off.png\") center no-repeat";
  465. }
  466. }
  467. }
  468. function processRepeatStateChangedEvent(xml){
  469. var _24=xml.getElementsByTagName("repeatState");
  470. if(_24.length>0){
  471. if(getData(_24[0])=="true"){
  472. repeatState=true;
  473. }else{
  474. repeatState=false;
  475. }
  476. }
  477. var _25=document.getElementById("repeatcontrol");
  478. if(_25){
  479. if(repeatState){
  480. _25.style.background="url(\"images/repeat_on.png\") center no-repeat";
  481. }else{
  482. _25.style.background="url(\"images/repeat_off.png\") center no-repeat";
  483. }
  484. }
  485. }
  486. function processSpeakerListChangedEvent(xml){
  487. var _27=false;
  488. var _28=document.getElementById("speakercontrolcontainer");
  489. var _29=document.getElementById("speakerlist");
  490. var _2a="";
  491. var _2b=xml.getElementsByTagName("speaker");
  492. for(var i=0;i<_2b.length;i++){
  493. var _2d=_2b[i];
  494. var _2e=_2d.getElementsByTagName("name");
  495. if(_2e.length>0){
  496. var _2f=getData(_2e[0]);
  497. var _2e=_2d.getElementsByTagName("id");
  498. if(_2e.length>0){
  499. var id=getDataInt(_2e[0]);
  500. _2a+="<li onclick=\"handleSpeakerSelection("+id+")\">"+_2f+"</li>";
  501. }
  502. }
  503. }
  504. _29.innerHTML=_2a;
  505. if(_2b.length>1){
  506. _28.style.display="block";
  507. }else{
  508. _28.style.display="none";
  509. }
  510. }
  511. function processMediaLibraryChangedEvent(){
  512. browseLibrary(currentBrowsePath,0,itemsPerPage);
  513. }
  514. function processResponse(){
  515. try{
  516. if(http_request.readyState!=4){
  517. return;
  518. }
  519. if(timeoutRequest){
  520. clearTimeout(timeoutRequest);
  521. timeoutRequest=0;
  522. }
  523. currentRequest="";
  524. isRequestPending=false;
  525. if(!http_request.status||http_request.status!=200){
  526. return;
  527. }
  528. if(!http_request.responseXML){
  529. return;
  530. }
  531. var _31=http_request.responseXML.documentElement;
  532. if(!_31){
  533. return;
  534. }
  535. try{
  536. if(_31.tagName=="GetCurrentMediaResponse"){
  537. processCurrentMediaChangedEvent(_31);
  538. }else{
  539. if(_31.tagName=="GetPlayingStateResponse"){
  540. processPlayingStateChangedEvent(_31);
  541. }else{
  542. if(_31.tagName=="GetVolumeResponse"){
  543. processVolumeChangedEvent(_31);
  544. }else{
  545. if(_31.tagName=="GetShuffleStateResponse"){
  546. processShuffleStateChangedEvent(_31);
  547. }else{
  548. if(_31.tagName=="GetRepeatStateResponse"){
  549. processRepeatStateChangedEvent(_31);
  550. }else{
  551. if(_31.tagName=="GetAlbumArtResponse"){
  552. processGetAlbumArtResponse(_31);
  553. }else{
  554. if(_31.tagName=="MediaSearchResponse"){
  555. processMediaSearchResponse(_31);
  556. }else{
  557. if(_31.tagName=="BrowseLibraryResponse"){
  558. processBrowseLibraryResponse(_31);
  559. }else{
  560. if(_31.tagName=="GetPlaylistItemsResponse"){
  561. processGetPlaylistItemsResponse(_31);
  562. }else{
  563. if(_31.tagName=="GetPlaylistPositionResponse"){
  564. processPlaylistPositionChangedEvent(_31);
  565. }else{
  566. if(_31.tagName=="GetSpeakerListResponse"){
  567. processSpeakerListChangedEvent(_31);
  568. }else{
  569. processResponseForErrors(_31);
  570. }
  571. }
  572. }
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. }
  580. }
  581. }
  582. catch(e){
  583. var _32="";
  584. if(_31.tagName){
  585. _32=_31.tagName;
  586. }
  587. writeLog("Error processing response "+_32,e);
  588. }
  589. if(pendingRequests.length>0){
  590. sendRequest(pendingRequests.pop());
  591. }
  592. }
  593. catch(e){
  594. writeLog("",e);
  595. return;
  596. }
  597. }
  598. function processResponseForErrors(xml){
  599. var _34=xml.getElementsByTagName("returnCode");
  600. if(_34.length>0){
  601. if(_34[0].firstChild){
  602. var _35=getDataInt(_34[0]);
  603. if(_35==106){
  604. alert("Please check \"Enable access for assistive devices\" on your Mac to use this feature.");
  605. }
  606. }
  607. }
  608. }
  609. function processGetAlbumArtResponse(xml){
  610. var _37="";
  611. var _38=xml.getElementsByTagName("artURL");
  612. if(_38.length>0){
  613. if(_38[0].firstChild){
  614. _37=getData(_38[0]);
  615. }
  616. }
  617. if(_37!=currentArtURL){
  618. currentArtURL=_37;
  619. if(onAlbumArtChanged){
  620. onAlbumArtChanged(currentArtURL);
  621. }
  622. }
  623. }
  624. function processBrowseLibraryResponse(xml){
  625. var _3a="<ul>";
  626. var _3b;
  627. var _3c="";
  628. var _3d="";
  629. var _3e=false;
  630. var _3f=false;
  631. var _40=-1;
  632. if(showingMediaLibAlphaJump){
  633. showMediaLibAlphaJump();
  634. }
  635. if(showingMediaLibSearch){
  636. showMediaLibSearch();
  637. }
  638. if(showingMediaLibSearchResults){
  639. showingMediaLibSearchResults=false;
  640. }
  641. if(showingMediaLib){
  642. hideAddressBar();
  643. }
  644. showingSearchResults=false;
  645. var _41=xml.getElementsByTagName("path");
  646. if(_41.length>0){
  647. if(_41[0].firstChild){
  648. currentBrowsePath=getData(_41[0]);
  649. }else{
  650. currentBrowsePath="";
  651. }
  652. }
  653. var _42="Media Library";
  654. if(currentBrowsePath.length>1){
  655. var pos=currentBrowsePath.lastIndexOf("\\");
  656. if(pos!=-1){
  657. pos++;
  658. _42=currentBrowsePath.substr(pos,currentBrowsePath.length-pos);
  659. if(_42.length>0){
  660. if(_42.charAt(_42.length-1)=="\\"){
  661. _42=_42.substr(0,_42.length-1);
  662. }
  663. }else{
  664. _42="Media Library";
  665. }
  666. }
  667. }
  668. if(document.getElementById){
  669. message=document.getElementById("libheadertitle");
  670. message.innerHTML=_42;
  671. }else{
  672. libheadertitle.innerHTML=_42;
  673. }
  674. _41=xml.getElementsByTagName("start");
  675. if(_41.length>0){
  676. mediaLibStart=getDataInt(_41[0]);
  677. }
  678. _41=xml.getElementsByTagName("totalCount");
  679. if(_41.length>0){
  680. mediaLibLength=getDataInt(_41[0]);
  681. }
  682. _41=xml.getElementsByTagName("alphaStartResult");
  683. if(_41.length>0){
  684. _40=getDataInt(_41[0]);
  685. }
  686. if(mediaLibLength>itemsPerPage){
  687. _3a+="<li>";
  688. if(mediaLibStart>0){
  689. _3a+="<div id=\"navprev\" onclick=\"mediaLibPrevPage()\">< Prev</div>";
  690. }else{
  691. _3a+="<div id=\"navprev\"> </div>";
  692. }
  693. _3a+="<div id=\"navalphajump\" onclick=\"showMediaLibAlphaJump()\">A-Z</div>";
  694. if((mediaLibStart+itemsPerPage)<mediaLibLength){
  695. _3a+="<div id=\"navnext\" onclick=\"mediaLibNextPage()\">Next ></div>";
  696. }else{
  697. _3a+="<div id=\"navnext\"> </div>";
  698. }
  699. _3a+="</li>";
  700. }
  701. var _44=xml.getElementsByTagName("result");
  702. for(var i=0;i<_44.length;i++){
  703. _3b=_44[i];
  704. var _46=null;
  705. _3e=false;
  706. _3f=true;
  707. _41=_3b.getElementsByTagName("type");
  708. if(_41.length>0){
  709. _3c=getData(_41[0]);
  710. if(_3c=="folder"){
  711. _3e=true;
  712. }
  713. }
  714. _41=_3b.getElementsByTagName("id");
  715. if(_41.length>0){
  716. _46=getData(_41[0]);
  717. }
  718. _41=_3b.getElementsByTagName("name");
  719. if(_41.length>0){
  720. var _42=getData(_41[0]);
  721. if(_3e){
  722. if(_42=="Music"){
  723. _3d="cd";
  724. }else{
  725. if(_42=="Videos"){
  726. _3d="video";
  727. }else{
  728. if(_42=="TV"){
  729. _3d="tv";
  730. }else{
  731. if(_42=="Genres"){
  732. _3d="genre";
  733. }else{
  734. if(_42=="Artists"){
  735. _3d="artist";
  736. }else{
  737. if(_42=="Albums"){
  738. _3d="album";
  739. }else{
  740. if(_42=="Playlists"){
  741. _3d="playlist";
  742. }else{
  743. if(_42=="Tracks"){
  744. _3d="music";
  745. }else{
  746. if(_42=="Podcasts"){
  747. _3d="podcast";
  748. }else{
  749. if(_42=="Radio"){
  750. _3d="podcast";
  751. }else{
  752. _3d="music";
  753. }
  754. }
  755. }
  756. }
  757. }
  758. }
  759. }
  760. }
  761. }
  762. }
  763. }else{
  764. if(_3c=="genre"){
  765. _3d="genre";
  766. }else{
  767. if(_3c=="artist"){
  768. _3d="artist";
  769. }else{
  770. if(_3c=="album"){
  771. _3d="album";
  772. }else{
  773. if(_3c=="podcast show"){
  774. _3d="podcast";
  775. }else{
  776. if(_3c=="tv series"){
  777. _3d="artist";
  778. _3f=false;
  779. }else{
  780. if(_3c=="playlist"){
  781. _3d="playlist";
  782. }else{
  783. if(_3c=="playlist folder"||_3c=="radio folder"){
  784. _3d="playlist_folder";
  785. _3f=false;
  786. }else{
  787. if(_3c=="info"){
  788. _3d="info";
  789. }else{
  790. _3d="music";
  791. }
  792. }
  793. }
  794. }
  795. }
  796. }
  797. }
  798. }
  799. }
  800. var _47=currentBrowsePath+"\\"+_42;
  801. _47=_47.replace(/\\/g,"\\\\");
  802. _47=_47.replace(/\'/g,"\\'");
  803. _47=_47.replace(/\"/g,""");
  804. _47="'"+_47+"'";
  805. _3a+="<li id=\"medialib_"+(mediaLibStart+i)+"\" ";
  806. if(!_46){
  807. if(!_3e&&_3f){
  808. _3a+="class=\"group\" ";
  809. }
  810. }else{
  811. if(_3c=="music"||_3c=="podcast"){
  812. _3a+="><div id=\"grouptitle\"";
  813. }
  814. }
  815. if(_46){
  816. _3a+="onclick=\"handlePlayItem(this, "+_46+")\"";
  817. }else{
  818. _3a+="onclick=\"handleBrowseLibrary(this, "+_47+")\"";
  819. }
  820. _3a+=">";
  821. if(_3d!=""){
  822. _3a+="<img src=\"images/"+_3d+".png\">";
  823. }
  824. _3a+=_42;
  825. if(!_46){
  826. if(!_3e&&_3f){
  827. _3a+="<div id=\"showactions\" onclick=\"showMediaLibActions("+_47+")\"></div>";
  828. }
  829. }else{
  830. if(_3c=="music"||_3c=="podcast"){
  831. _3a+="</div><div id=\"showactions\" onclick=\"handleSingleItemAdd(this, "+_46+")\"></div>";
  832. }
  833. }
  834. _3a+="</li>";
  835. }
  836. }
  837. if(mediaLibLength>itemsPerPage){
  838. _3a+="<li>";
  839. if(mediaLibStart>0){
  840. _3a+="<div id=\"navprev\" onclick=\"mediaLibPrevPage()\">< Prev</div>";
  841. }else{
  842. _3a+="<div id=\"navprev\"> </div>";
  843. }
  844. _3a+="<div id=\"navalphajump\" onclick=\"showMediaLibAlphaJump()\">A-Z</div>";
  845. if((mediaLibStart+itemsPerPage)<mediaLibLength){
  846. _3a+="<div id=\"navnext\" onclick=\"mediaLibNextPage()\">Next ></div>";
  847. }else{
  848. _3a+="<div id=\"navnext\"> </div>";
  849. }
  850. _3a+="</li>";
  851. }
  852. _3a+="</ul>";
  853. if(document.getElementById){
  854. message=document.getElementById("libcontents");
  855. message.innerHTML=_3a;
  856. }
  857. if(_40!=-1&&showingMediaLib){
  858. var _48=document.getElementById("medialib_"+_40);
  859. if(_48){
  860. slideTo(_48.offsetTop);
  861. }
  862. }
  863. }
  864. function processMediaSearchResponse(xml){
  865. var _4a="<ul>";
  866. var _4b;
  867. hideAddressBar();
  868. if(!showingMediaLibSearchResults){
  869. addBrowseHistoryEntry();
  870. showingMediaLibSearchResults=true;
  871. if(document.getElementById){
  872. message=document.getElementById("libheadertitle");
  873. message.innerHTML="Search";
  874. }else{
  875. libheadertitle.innerHTML="Search";
  876. }
  877. }
  878. _4c=xml.getElementsByTagName("start");
  879. if(_4c.length>0){
  880. mediaLibStart=getDataInt(_4c[0]);
  881. }else{
  882. mediaLibStart=0;
  883. }
  884. _4c=xml.getElementsByTagName("totalCount");
  885. if(_4c.length>0){
  886. mediaLibLength=getDataInt(_4c[0]);
  887. }
  888. var _4d=xml.getElementsByTagName("result");
  889. for(var i=0;i<_4d.length;i++){
  890. _4b=_4d[i];
  891. var _4f="";
  892. var _50=null;
  893. var _51="music";
  894. var _52="music";
  895. var _53="";
  896. var _4c=_4b.getElementsByTagName("type");
  897. if(_4c.length>0){
  898. _4f=getData(_4c[0]);
  899. _51=_4f;
  900. if(_51=="podcast show"){
  901. _51="podcast";
  902. }else{
  903. if(_51=="podcast"){
  904. _51="music";
  905. }
  906. }
  907. }
  908. _4c=_4b.getElementsByTagName("id");
  909. if(_4c.length>0){
  910. _50=getData(_4c[0]);
  911. }
  912. _4c=_4b.getElementsByTagName("name");
  913. if(_4c.length>0){
  914. var _54=getData(_4c[0]);
  915. _4a+="<li";
  916. if(_50){
  917. if(_4f!="playlist"){
  918. _4a+="><div id=\"grouptitle\" onclick=\"handlePlayItem(this, "+_50+")\"";
  919. }else{
  920. _4a+=" onclick=\"handlePlayItem(this, "+_50+")\"";
  921. }
  922. }else{
  923. _53="\\Music\\";
  924. if(_4f=="genre"){
  925. _53+="Genres\\";
  926. }else{
  927. if(_4f=="artist"){
  928. _53+="Artists\\";
  929. }else{
  930. if(_4f=="album"){
  931. _53+="Albums\\";
  932. }else{
  933. if(_4f=="podcast show"){
  934. _53="\\Podcasts\\";
  935. }
  936. }
  937. }
  938. }
  939. _53+=_54;
  940. _53=_53.replace(/\\/g,"\\\\");
  941. _53=_53.replace(/\'/g,"\\'");
  942. _53=_53.replace(/\"/g,""");
  943. _53="'"+_53+"'";
  944. _4a+=" class=\"group\" onclick=\"handleBrowseLibrary(this, "+_53+")\"";
  945. }
  946. _4a+="><img src=\"images/"+_51+".png\">"+_54;
  947. if(!_50){
  948. _4a+="<div id=\"showactions\" onclick=\"showMediaLibActions("+_53+")\"></div>";
  949. }else{
  950. if(_4f!="playlist"){
  951. _4a+="</div><div id=\"showactions\" onclick=\"handleSingleItemAdd(this, "+_50+")\"></div>";
  952. }
  953. }
  954. _4a+="</li>";
  955. }
  956. }
  957. _4a+="</ul>";
  958. if(document.getElementById){
  959. message=document.getElementById("libcontents");
  960. message.innerHTML=_4a;
  961. }else{
  962. libcontents.innerHTML=_4a;
  963. }
  964. showingSearchResults=true;
  965. }
  966. function processGetPlaylistItemsResponse(xml){
  967. var _56=0;
  968. var _57="<ul>";
  969. if(showingPlaylist){
  970. hideAddressBar();
  971. }
  972. var _58=xml.getElementsByTagName("start");
  973. if(_58.length>0){
  974. playlistStart=getDataInt(_58[0]);
  975. }else{
  976. playlistStart=0;
  977. }
  978. _58=xml.getElementsByTagName("totalCount");
  979. if(_58.length>0){
  980. playlistLength=getDataInt(_58[0]);
  981. }
  982. if(playlistLength>itemsPerPage){
  983. _57+="<li>";
  984. if(playlistStart>0){
  985. _57+="<div id=\"navprev\" onclick=\"playlistPrevPage()\">< Prev</div>";
  986. }
  987. if((playlistStart+itemsPerPage)<playlistLength){
  988. _57+="<div id=\"navnext\" onclick=\"playlistNextPage()\">Next ></div>";
  989. }
  990. _57+="</li>";
  991. }
  992. _58=xml.getElementsByTagName("item");
  993. for(i=0;i<_58.length;i++){
  994. _56=playlistStart+i;
  995. _57+="<li id=\"playlist_"+_56+"\" onclick=\"handlePlaylistJump(this, "+_56+")\"";
  996. if(_56==playlistPosition){
  997. _57+="class=\"playing\" ";
  998. }
  999. var _59="";
  1000. var _5a="";
  1001. var pos=getData(_58[i]).indexOf(" - ");
  1002. if(pos!=-1){
  1003. _59=getData(_58[i]).substr(0,pos);
  1004. pos+=3;
  1005. _5a=getData(_58[i]).substr(pos,getData(_58[i]).length-pos);
  1006. }else{
  1007. _5a=getData(_58[i]);
  1008. }
  1009. _57+=">"+_5a+" <span class=\"listArtist\">"+_59+"</span></li>";
  1010. }
  1011. if(_58.length<1){
  1012. _57+="<li>No items</li>";
  1013. }
  1014. if(playlistLength>itemsPerPage){
  1015. _57+="<li>";
  1016. if(playlistStart>0){
  1017. _57+="<div id=\"navprev\" onclick=\"playlistPrevPage()\">< Prev</div>";
  1018. }
  1019. if((playlistStart+itemsPerPage)<playlistLength){
  1020. _57+="<div id=\"navnext\" onclick=\"playlistNextPage()\">Next ></div>";
  1021. }
  1022. _57+="</li>";
  1023. }
  1024. _57+="</ul>";
  1025. if(document.getElementById){
  1026. message=document.getElementById("playlistcontents");
  1027. message.innerHTML=_57;
  1028. }else{
  1029. playlist.innerHTML=_57;
  1030. }
  1031. if(showPlaylistItemOnPageLoad){
  1032. showPlaylistItemOnPageLoad=false;
  1033. if(playlistPosition>=playlistStart&&playlistPosition<(playlistStart+itemsPerPage)){
  1034. showCurrentPlaylistItem();
  1035. }
  1036. }
  1037. }
  1038. function playpause(){
  1039. sendRequest("<PlayPauseRequest></PlayPauseRequest>");
  1040. }
  1041. function play(){
  1042. sendRequest("<PlayRequest></PlayRequest>");
  1043. }
  1044. function pause(){
  1045. sendRequest("<PauseRequest></PauseRequest>");
  1046. }
  1047. function stop(){
  1048. sendRequest("<StopRequest></StopRequest>");
  1049. }
  1050. function prev(){
  1051. sendRequest("<PreviousItemRequest></PreviousItemRequest>");
  1052. }
  1053. function next(){
  1054. sendRequest("<NextItemRequest></NextItemRequest>");
  1055. }
  1056. function playItem(_5c){
  1057. if(isNaN(Number(_5c))){
  1058. sendRequest("<PlayMediaRequest><libPath>"+escape(_5c)+"</libPath></PlayMediaRequest>");
  1059. }else{
  1060. sendRequest("<PlayMediaRequest><id>"+_5c+"</id></PlayMediaRequest>");
  1061. }
  1062. }
  1063. function playlistAdd(_5d){
  1064. if(isNaN(Number(_5d))){
  1065. sendRequest("<PlaylistAddRequest><libPath>"+escape(_5d)+"</libPath></PlaylistAddRequest>");
  1066. }else{
  1067. sendRequest("<PlaylistAddRequest><id>"+_5d+"</id></PlaylistAddRequest>");
  1068. }
  1069. }
  1070. function setPlaylistPosition(_5e){
  1071. sendRequest("<SetPlaylistPositionRequest><position>"+_5e+"</position></SetPlaylistPositionRequest>");
  1072. }
  1073. function refreshState(){
  1074. sendRequest("<GetCurrentMediaRequest></GetCurrentMediaRequest>");
  1075. }
  1076. function browseLibrary(_5f,_60,_61,_62){
  1077. _60=(_60==null)?0:_60;
  1078. _61=(_61==null)?-1:_61;
  1079. _62=(_62==null)?true:_62;
  1080. var _63;
  1081. if(isNaN(Number(_60))){
  1082. _63="<BrowseLibraryRequest><start>"+_60+"</start><count>"+_61+"</count><path>"+escape(_5f)+"</path>";
  1083. }else{
  1084. if(_60<0){
  1085. _60=0;
  1086. }
  1087. _63="<BrowseLibraryRequest><start>"+_60+"</start><count>"+_61+"</count><path>"+escape(_5f)+"</path>";
  1088. }
  1089. if(_62){
  1090. _63+="<includeTotalCount>true</includeTotalCount>";
  1091. }
  1092. _63+="</BrowseLibraryRequest>";
  1093. sendRequest(_63);
  1094. }
  1095. function searchLibrary(_64,_65,_66){
  1096. _65=(_65==null)?0:_65;
  1097. _66=(_66==null)?-1:_66;
  1098. if(_65<0){
  1099. _65=0;
  1100. }
  1101. sendRequest("<MediaSearchRequest><start>"+_65+"</start><count>"+_66+"</count><any>"+escape(_64)+"</any></MediaSearchRequest>");
  1102. }
  1103. function getPlaylistItems(_67,_68,_69){
  1104. _67=(_67==null)?0:_67;
  1105. _68=(_68==null)?-1:_68;
  1106. _69=(_69==null)?true:_69;
  1107. var _6a="<GetPlaylistItemsRequest><start>"+_67+"</start><count>"+_68+"</count>";
  1108. if(_69){
  1109. _6a+="<includeTotalCount>true</includeTotalCount>";
  1110. }
  1111. _6a+="</GetPlaylistItemsRequest>";
  1112. sendRequest(_6a);
  1113. }
  1114. function toggleShuffleState(){
  1115. sendRequest("<SetShuffleStateRequest><shuffleState>"+!shuffleState+"</shuffleState></SetShuffleStateRequest>");
  1116. }
  1117. function toggleRepeatState(){
  1118. sendRequest("<SetRepeatStateRequest><repeatState>"+!repeatState+"</repeatState></SetRepeatStateRequest>");
  1119. }
  1120. function setVolume(_6b){
  1121. if(_6b<0){
  1122. _6b=0;
  1123. }else{
  1124. if(_6b>100){
  1125. _6b=100;
  1126. }
  1127. }
  1128. ignoreNextVolumeUpdate=true;
  1129. currentVolume=_6b;
  1130. sendRequest("<SetVolumeRequest><volume>"+_6b+"</volume></SetVolumeRequest>");
  1131. }
  1132. function volumeUp(){
  1133. setVolume(currentVolume+volumeIncrement);
  1134. onVolumeChanged(currentVolume);
  1135. }
  1136. function volumeDown(){
  1137. setVolume(currentVolume-volumeIncrement);
  1138. onVolumeChanged(currentVolume);
  1139. }
  1140. function setRating(_6c){
  1141. if(_6c<0){
  1142. _6c=0;
  1143. }else{
  1144. if(_6c>100){
  1145. _6c=100;
  1146. }
  1147. }
  1148. sendRequest("<SetTrackRatingRequest><rating>"+_6c+"</rating></SetTrackRatingRequest>");
  1149. }
  1150. function selectSpeaker(id){
  1151. sendRequest("<SelectSpeakerRequest><id>"+id+"</id></SelectSpeakerRequest>");
  1152. }
  1153. function enableSpeaker(id,_6f){
  1154. sendRequest("<EnableSpeakerRequest><id>"+id+"</id><enabled>"+_6f+"</enabled></EnableSpeakerRequest>");
  1155. }
  1156. function requestInitialState(){
  1157. sendRequest("<GetPlayingStateRequest></GetPlayingStateRequest>");
  1158. sendRequest("<GetCurrentMediaRequest></GetCurrentMediaRequest>");
  1159. sendRequest("<GetVolumeRequest></GetVolumeRequest>");
  1160. sendRequest("<GetShuffleStateRequest></GetShuffleStateRequest>");
  1161. sendRequest("<GetRepeatStateRequest></GetRepeatStateRequest>");
  1162. sendRequest("<GetPlaylistPositionRequest></GetPlaylistPositionRequest>");
  1163. sendRequest("<GetSpeakerListRequest></GetSpeakerListRequest>");
  1164. browseLibrary(currentBrowsePath,mediaLibStart,itemsPerPage);
  1165. getPlaylistItems(0,itemsPerPage);
  1166. }
  1167. function testForMobileSafari(){
  1168. try{
  1169. if(navigator.userAgent){
  1170. var pos=navigator.userAgent.indexOf(" Mobile/");
  1171. if(pos!=-1){
  1172. pos=navigator.userAgent.indexOf(" Safari/");
  1173. if(pos!=-1){
  1174. return true;
  1175. }
  1176. }
  1177. }
  1178. }
  1179. catch(e){
  1180. }
  1181. return false;
  1182. }
  1183. function onLoad(){
  1184. isMobileSafari=testForMobileSafari();
  1185. if(isMobileSafari&&location.hash!=navCurrent&&location.hash!="NowPlaying"){
  1186. navCurrent="NowPlaying";
  1187. location.hash=navCurrent;
  1188. }
  1189. uiMonitor();
  1190. setTimeout(setupApp,100);
  1191. }
  1192. function setupApp(){
  1193. hideAddressBar();
  1194. createQueue();
  1195. setInterval(sleepMonitor,1000);
  1196. setInterval(uiMonitor,300);
  1197. var val=getCookie("useMultipleSpeakers");
  1198. if(val!=null&&val=="true"&&!useMultipleSpeakers){
  1199. toggleUseMultipleSpeakers();
  1200. }
  1201. }
  1202. function hideAddressBar(){
  1203. window.scrollTo(0,1);
  1204. }
  1205. function backToNowPlaying(){
  1206. if(isMobileSafari){
  1207. if(navHistory.length>0){
  1208. history.back();
  1209. }else{
  1210. setLocation("",false);
  1211. }
  1212. }else{
  1213. if(showingMediaLib){
  1214. showMediaLib(false);
  1215. }else{
  1216. if(showingPlaylist){
  1217. showPlaylist(false);
  1218. }else{
  1219. if(showingSpeakers){
  1220. showSpeakers(false);
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. function showMediaLib(_72){
  1227. if(document.getElementById){
  1228. hideAddressBar();
  1229. var _73=document.getElementById("medialib");
  1230. var _74=document.getElementById("container");
  1231. if(!showingMediaLib){
  1232. setLocation("Media",_72);
  1233. if(showingPlaylist){
  1234. showPlaylist();
  1235. }
  1236. showingMediaLib=true;
  1237. _73.style.overflow="visible";
  1238. _73.style.visibility="visible";
  1239. _74.style.overflow="visible";
  1240. }else{
  1241. if(showingMediaLibSearch){
  1242. showMediaLibSearch();
  1243. }
  1244. if(showingMediaLibAlphaJump){
  1245. showMediaLibAlphaJump();
  1246. }
  1247. showingMediaLib=false;
  1248. _73.style.visibility="hidden";
  1249. _73.style.overflow="hidden";
  1250. _74.style.overflow="hidden";
  1251. }
  1252. }
  1253. }
  1254. function showPlaylist(_75){
  1255. if(document.getElementById){
  1256. var _76=document.getElementById("playlist");
  1257. var _77=document.getElementById("container");
  1258. if(!showingPlaylist){
  1259. setLocation("Playlist",_75);
  1260. if(showingMediaLib){
  1261. showMediaLib(false);
  1262. }
  1263. hideAddressBar();
  1264. _76.style.overflow="visible";
  1265. _76.style.visibility="visible";
  1266. _77.style.overflow="visible";
  1267. showingPlaylist=true;
  1268. }else{
  1269. _76.style.visibility="hidden";
  1270. _76.style.overflow="hidden";
  1271. _77.style.overflow="hidden";
  1272. showingPlaylist=false;
  1273. hideAddressBar();
  1274. }
  1275. }
  1276. }
  1277. function showSpeakers(_78){
  1278. if(document.getElementById){
  1279. var _79=document.getElementById("speakers");
  1280. var _7a=document.getElementById("container");
  1281. if(!showingSpeakers){
  1282. setLocation("Speakers",_78);
  1283. hideAddressBar();
  1284. _79.style.overflow="visible";
  1285. _79.style.visibility="visible";
  1286. _7a.style.overflow="visible";
  1287. showingSpeakers=true;
  1288. }else{
  1289. _79.style.visibility="hidden";
  1290. _79.style.overflow="hidden";
  1291. _7a.style.overflow="hidden";
  1292. showingSpeakers=false;
  1293. hideAddressBar();
  1294. }
  1295. }
  1296. }
  1297. function showMediaLibSearch(){
  1298. if(showingMediaLibAlphaJump){
  1299. showMediaLibAlphaJump();
  1300. }
  1301. if(document.getElementById){
  1302. var _7b=document.getElementById("libsearchfield");
  1303. if(!showingMediaLibSearch){
  1304. _7b.style.visibility="visible";
  1305. var _7c=document.getElementById("searchInput");
  1306. if(_7c){
  1307. _7c.focus();
  1308. }
  1309. searchInputTimer=setInterval(searchInputMonitor,300);
  1310. showingMediaLibSearch=true;
  1311. }else{
  1312. _7b.style.visibility="hidden";
  1313. var _7c=document.getElementById("searchInput");
  1314. _7c.value="";
  1315. if(searchInputTimer){
  1316. clearInterval(searchInputTimer);
  1317. searchInputTimer=null;
  1318. }
  1319. showingMediaLibSearch=false;
  1320. }
  1321. }
  1322. }
  1323. function showMediaLibActions(_7d){
  1324. if(document.getElementById){
  1325. var _7e=document.getElementById("itemactions");
  1326. currentActionItem=_7d;
  1327. if(!showingMediaLibActions){
  1328. hideAddressBar();
  1329. _7e.style.visibility="visible";
  1330. showingMediaLibActions=true;
  1331. }else{
  1332. _7e.style.visibility="hidden";
  1333. showingMediaLibActions=false;
  1334. hideAddressBar();
  1335. }
  1336. }
  1337. }
  1338. function showMediaLibAlphaJump(){
  1339. if(document.getElementById){
  1340. var _7f=document.getElementById("alphajump");
  1341. if(!showingMediaLibAlphaJump){
  1342. hideAddressBar();
  1343. _7f.style.visibility="visible";
  1344. showingMediaLibAlphaJump=true;
  1345. }else{
  1346. _7f.style.visibility="hidden";
  1347. showingMediaLibAlphaJump=false;
  1348. hideAddressBar();
  1349. }
  1350. }
  1351. }
  1352. function showCurrentPlaylistItem(){
  1353. if(playlistPosition<playlistStart||playlistPosition>=(playlistStart+itemsPerPage)){
  1354. var _80=parseInt(playlistPosition/itemsPerPage);
  1355. getPlaylistItems(_80*itemsPerPage,itemsPerPage);
  1356. showPlaylistItemOnPageLoad=true;
  1357. return;
  1358. }
  1359. if(!showingPlaylist){
  1360. showPlaylist();
  1361. setTimeout(showCurrentPlaylistItem,100);
  1362. return;
  1363. }
  1364. var _81=document.getElementById("playlist_"+playlistPosition);
  1365. if(_81){
  1366. window.scrollTo(0,_81.offsetTop);
  1367. }
  1368. }
  1369. function addBrowseHistoryEntry(){
  1370. var _82=new BrowseHistoryEntry();
  1371. _82.start=mediaLibStart;
  1372. _82.search=showingMediaLibSearchResults;
  1373. if(!_82.search){
  1374. _82.path=currentBrowsePath;
  1375. }else{
  1376. _82.path=currentSearchKeywords;
  1377. }
  1378. browseHistory.push(_82);
  1379. }
  1380. function navigateLibBack(){
  1381. if(browseHistory.length<1){
  1382. backToNowPlaying();
  1383. return;
  1384. }
  1385. var _83=browseHistory.pop();
  1386. if(!_83.search){
  1387. browseLibrary(_83.path,_83.start,itemsPerPage);
  1388. }else{
  1389. if(!showingMediaLibSearchResults){
  1390. showingMediaLibSearchResults=true;
  1391. if(document.getElementById){
  1392. message=document.getElementById("libheadertitle");
  1393. message.innerHTML="Search";
  1394. }else{
  1395. libheadertitle.innerHTML="Search";
  1396. }
  1397. }
  1398. currentSearchKeywords=_83.path;
  1399. searchLibrary(_83.path,_83.start,itemsPerPage);
  1400. }
  1401. }
  1402. function onAlbumArtChanged(url){
  1403. if(url==""){
  1404. url="images/no_artwork.jpg";
  1405. }
  1406. var _85="";
  1407. if(url!=""){
  1408. _85="<img id=\"artwork\" src=\""+url+"\">";
  1409. }
  1410. if(document.getElementById){
  1411. var _86=document.getElementById("albumart");
  1412. _86.innerHTML=_85;
  1413. }else{
  1414. _86.innerHTML=_85;
  1415. }
  1416. }
  1417. function onRatingChanged(_87){
  1418. var _88=_87/20;
  1419. for(i=1;i<=5;i++){
  1420. var _89=document.getElementById("star"+i);
  1421. if(_89){
  1422. if(i<=_88){
  1423. _89.className="starred";
  1424. }else{
  1425. _89.className="";
  1426. }
  1427. }
  1428. }
  1429. }
  1430. function onVolumeChanged(_8a){
  1431. var _8b=document.getElementById("volumecontrol");
  1432. var _8c=document.getElementById("volumecontrol_on");
  1433. if(_8c&&_8b){
  1434. var _8d=(_8b.offsetWidth-20);
  1435. _8d*=(currentVolume/100);
  1436. _8c.style.width=_8d+"px";
  1437. }
  1438. }
  1439. function searchInput_keyUp(){
  1440. if(!showingMediaLibSearch){
  1441. return;
  1442. }
  1443. var _8e=document.getElementById("searchInput");
  1444. if(_8e.value.length>2){
  1445. currentSearchKeywords=_8e.value;
  1446. searchLibrary(_8e.value,0,itemsPerPage);
  1447. }else{
  1448. var _8f=document.getElementById("libcontents");
  1449. _8f.innerHTML="";
  1450. }
  1451. }
  1452. function toggleControls(){
  1453. var _90=document.getElementById("subcontrols");
  1454. hideAddressBar();
  1455. if(!showingSubControls){
  1456. _90.style.visibility="visible";
  1457. showingSubControls=true;
  1458. }else{
  1459. _90.style.visibility="hidden";
  1460. showingSubControls=false;
  1461. }
  1462. }
  1463. function handleBrowseLibrary(_91,_92){
  1464. hideAddressBar();
  1465. if(showingMediaLib){
  1466. addBrowseHistoryEntry();
  1467. }
  1468. browseLibrary(_92,0,itemsPerPage);
  1469. }
  1470. function handlePlayItem(_93,_94){
  1471. backToNowPlaying();
  1472. playItem(_94);
  1473. }
  1474. function handlePlaylistJump(_95,_96){
  1475. backToNowPlaying();
  1476. setPlaylistPosition(_96);
  1477. }
  1478. function handleRating(_97){
  1479. currentRating=_97;
  1480. onRatingChanged(_97);
  1481. setRating(_97);
  1482. }
  1483. function handleActionPlay(){
  1484. playItem(currentActionItem);
  1485. showMediaLibActions();
  1486. }
  1487. function handleActionAdd(){
  1488. playlistAdd(currentActionItem);
  1489. showMediaLibActions();
  1490. }
  1491. function handleSingleItemAdd(_98,_99){
  1492. _98.className="off";
  1493. playlistAdd(_99);
  1494. }
  1495. function handleSpeakerSelection(id){
  1496. if(!useMultipleSpeakers){
  1497. backToNowPlaying();
  1498. selectSpeaker(id);
  1499. }else{
  1500. enableSpeaker(id,true);
  1501. }
  1502. }
  1503. function toggleUseMultipleSpeakers(){
  1504. useMultipleSpeakers=!useMultipleSpeakers;
  1505. var _9b=document.getElementById("speakermsg");
  1506. var _9c=document.getElementById("multiplespeakerbtn");
  1507. _9c.setAttribute("enabled",useMultipleSpeakers);
  1508. if(useMultipleSpeakers){
  1509. _9b.innerHTML="Tap on a speaker name to toggle its audio on or off.";
  1510. }else{
  1511. _9b.innerHTML="Tap on a speaker name to send all audio to that speaker.";
  1512. }
  1513. if(useMultipleSpeakers){
  1514. setCookie("useMultipleSpeakers","true",365);
  1515. }else{
  1516. deleteCookie("useMultipleSpeakers");
  1517. }
  1518. }
  1519. function mediaLibPrevPage(){
  1520. browseLibrary(currentBrowsePath,mediaLibStart-itemsPerPage,itemsPerPage,false);
  1521. }
  1522. function mediaLibNextPage(){
  1523. browseLibrary(currentBrowsePath,mediaLibStart+itemsPerPage,itemsPerPage,false);
  1524. }
  1525. function mediaLibJumpToLetter(_9d){
  1526. browseLibrary(currentBrowsePath,_9d,itemsPerPage,false);
  1527. if(showingMediaLibAlphaJump){
  1528. showMediaLibAlphaJump();
  1529. }
  1530. }
  1531. function playlistPrevPage(){
  1532. getPlaylistItems(playlistStart-itemsPerPage,itemsPerPage,false);
  1533. }
  1534. function playlistNextPage(){
  1535. getPlaylistItems(playlistStart+itemsPerPage,itemsPerPage,false);
  1536. }
  1537. function adjustVolume(_9e){
  1538. var _9f=_9e.offsetX?(_9e.offsetX):_9e.pageX-document.getElementById("volumecontrol").offsetLeft;
  1539. var _a0=document.getElementById("volumecontrol");
  1540. var _a1=document.getElementById("volumecontrol_on");
  1541. if(_a1&&_a0){
  1542. var _a2;
  1543. if(_9f>10&&_9f<_a0.offsetWidth-10){
  1544. _a2=_9f/(_a0.offsetWidth-20);
  1545. _a2*=100;
  1546. _a2=parseInt(_a2);
  1547. }else{
  1548. if(_9f<10){
  1549. _a2=0;
  1550. }else{
  1551. _a2=100;
  1552. }
  1553. }
  1554. setVolume(_a2);
  1555. onVolumeChanged(currentVolume);
  1556. }
  1557. }
  1558. function setLocation(_a3,_a4){
  1559. if(!isMobileSafari){
  1560. return;
  1561. }
  1562. if(_a4==null||_a4==true){
  1563. navHistory.push(location.hash);
  1564. }
  1565. navCurrent=_a3;
  1566. location.hash=navCurrent;
  1567. }
  1568. function slideTo(pos){
  1569. setTimeout(function(){
  1570. var _a6=100;
  1571. var _a7=setInterval(slide,0);
  1572. function slide(){
  1573. _a6-=slideSpeed;
  1574. if(_a6<=0){
  1575. _a6=0;
  1576. clearInterval(_a7);
  1577. }
  1578. var x=((100-_a6)/100)*pos;
  1579. scrollTo(0,x);
  1580. }
  1581. },0);
  1582. }
  1583. function setCookie(_a9,_aa,_ab){
  1584. var _ac="";
  1585. if(_ab){
  1586. var _ad=new Date();
  1587. _ad.setTime(_ad.getTime()+(_ab*24*60*60*1000));
  1588. _ac="; expires="+_ad.toGMTString();
  1589. }
  1590. document.cookie=_a9+"="+_aa+_ac+"; path=/";
  1591. }
  1592. function getCookie(_ae){
  1593. _ae+="=";
  1594. var _af=document.cookie.split(";");
  1595. for(var i=0;i<_af.length;i++){
  1596. var _b1=_af[i];
  1597. while(_b1.charAt(0)==" "){
  1598. _b1=_b1.substring(1,_b1.length);
  1599. }
  1600. if(_b1.indexOf(_ae)==0){
  1601. return _b1.substring(_ae.length,_b1.length);
  1602. }
  1603. }
  1604. return null;
  1605. }
  1606. function deleteCookie(_b2){
  1607. setCookie(_b2,"",-1);
  1608. }
  1609. function searchInputMonitor(){
  1610. if(!showingMediaLibSearch){
  1611. return;
  1612. }
  1613. var _b3=document.getElementById("searchInput");
  1614. if(_b3.value!=searchInput){
  1615. searchInput=_b3.value;
  1616. if(searchInput.length>2){
  1617. currentSearchKeywords=searchInput;
  1618. searchLibrary(searchInput,0,itemsPerPage);
  1619. }else{
  1620. var _b4=document.getElementById("libcontents");
  1621. _b4.innerHTML="";
  1622. }
  1623. }
  1624. }
  1625. function uiMonitor(){
  1626. if(!isMobileSafari){
  1627. return;
  1628. }
  1629. if(currentWindowWidth!=window.innerWidth){
  1630. currentWindowWidth=window.innerWidth;
  1631. var _b5=(currentWindowWidth==320)?"portrait":"landscape";
  1632. document.body.setAttribute("orientation",_b5);
  1633. if(!showingPlaylist&&!showingMediaLib){
  1634. hideAddressBar();
  1635. }
  1636. }
  1637. if(location.hash!=navCurrent){
  1638. var _b6=location.hash.substr(navHash.length);
  1639. if(_b6==navCurrent){
  1640. navCurrent=location.hash;
  1641. verifyQueueActive();
  1642. return;
  1643. }
  1644. navCurrent=location.hash;
  1645. if(navHistory.length>0&&location.hash==navHistory[navHistory.length-1]){
  1646. navHistory.pop();
  1647. }else{
  1648. navHistory.push(location.hash);
  1649. }
  1650. if(_b6=="Media"){
  1651. if(!showingMediaLib){
  1652. showMediaLib(false);
  1653. }
  1654. }else{
  1655. if(_b6=="Playlist"){
  1656. if(!showingPlaylist){
  1657. showPlaylist(false);
  1658. }
  1659. }else{
  1660. if(_b6=="Speakers"){
  1661. if(!showingSpeakers){
  1662. showSpeakers(false);
  1663. }
  1664. }else{
  1665. if(showingMediaLib){
  1666. showMediaLib(false);
  1667. }else{
  1668. if(showingPlaylist){
  1669. showPlaylist(false);
  1670. }else{
  1671. if(showingSpeakers){
  1672. showSpeakers(false);
  1673. }
  1674. }
  1675. }
  1676. }
  1677. }
  1678. }
  1679. verifyQueueActive();
  1680. }
  1681. }
  1682. function sleepMonitor(){
  1683. var _b7=new Date();
  1684. if((_b7-lastMonitorTime>7000)&&(!linkRecoveryActive)){
  1685. enterLinkRecovery();
  1686. }
  1687. lastMonitorTime=_b7;
  1688. }
  1689. function enterLinkRecovery(){
  1690. if(linkRecoveryActive){
  1691. return;
  1692. }
  1693. linkRecoveryRequests.splice(0,linkRecoveryRequests.length);
  1694. exitLinkRecovery();
  1695. if(timerQueue){
  1696. clearInterval(timerQueue);
  1697. timerQueue=0;
  1698. }
  1699. if(http_request){
  1700. http_request.abort();
  1701. http_request=null;
  1702. }
  1703. isRequestPending=false;
  1704. pendingRequests.splice(0,pendingRequests.length);
  1705. linkRecoveryActive=true;
  1706. linkRecoveryStart=new Date();
  1707. timeoutCheckQueue=setTimeout(checkQueue,2000);
  1708. }
  1709. function exitLinkRecovery(){
  1710. if(timeoutCheckQueue){
  1711. clearTimeout(timeoutCheckQueue);
  1712. timeoutCheckQueue=0;
  1713. }
  1714. if(timeoutPing){
  1715. clearTimeout(timeoutPing);
  1716. timeoutPing=0;
  1717. }
  1718. if(timeoutPingResponse){
  1719. clearTimeout(timeoutPingResponse);
  1720. timeoutPingResponse=0;
  1721. }
  1722. if(timeoutVerifyPingQueue){
  1723. clearTimeout(timeoutVerifyPingQueue);
  1724. timeoutVerifyPingQueue=0;
  1725. }
  1726. if(timerQueue==0){
  1727. if(usePersistentConnection){
  1728. timerQueue=setInterval(verifyQueueActive,5000);
  1729. }else{
  1730. timerQueue=setInterval(getQueuedEvents,1000);
  1731. }
  1732. }
  1733. if(link_request&&link_request.readyState!=4){
  1734. link_request.abort();
  1735. link_request=null;
  1736. }
  1737. isLinkRequestPending=false;
  1738. linkRecoveryActive=false;
  1739. while(linkRecoveryRequests.length>0){
  1740. sendRequest(linkRecoveryRequests.pop());
  1741. }
  1742. }
  1743. function checkQueue(){
  1744. if(lastEventTime<=linkRecoveryStart){
  1745. pingServer();
  1746. }else{
  1747. exitLinkRecovery();
  1748. }
  1749. }
  1750. function pingServer(){
  1751. if(isLinkRequestPending&&link_request){
  1752. link_request.abort();
  1753. }
  1754. link_request=createHTTPRequest();
  1755. isLinkRequestPending=true;
  1756. receivedPingResponse=false;
  1757. link_request.open("POST","/q",true);
  1758. link_request.setRequestHeader("Cache-Control","no-cache");
  1759. link_request.setRequestHeader("If-Modified-Since","Wed, 15 Nov 1995 00:00:00 GMT");
  1760. link_request.onreadystatechange=processLinkResponse;
  1761. link_request.send("action=ping&id="+queueID);
  1762. timeoutPingResponse=setTimeout(verifyPingResponse,1000);
  1763. }
  1764. function verifyPingResponse(){
  1765. if(!receivedPingResponse){
  1766. if(queue_request){
  1767. queue_request.abort();
  1768. queue_request=null;
  1769. isQueueRequestPending=false;
  1770. }
  1771. pingServer();
  1772. }
  1773. }
  1774. function processLinkResponse(){
  1775. try{
  1776. if(link_request.readyState!=4){
  1777. return;
  1778. }
  1779. isLinkRequestPending=false;
  1780. if(!link_request.status||link_request.status!=200){
  1781. return;
  1782. }
  1783. if(!link_request.responseText){
  1784. return;
  1785. }
  1786. if(link_request.responseText=="ok"){
  1787. if(timeoutPingResponse){
  1788. clearTimeout(timeoutPingResponse);
  1789. timeoutPingResponse=0;
  1790. }
  1791. receivedPingResponse=true;
  1792. if(linkRecoveryActive){
  1793. if(timeoutVerifyPingQueue){
  1794. clearTimeout(timeoutVerifyPingQueue);
  1795. }
  1796. timeoutVerifyPingQueue=setTimeout(verifyQueuePing,2000);
  1797. }
  1798. getQueuedEvents();
  1799. }else{
  1800. if(link_request.responseText=="not found"){
  1801. if(linkRecoveryActive){
  1802. exitLinkRecovery();
  1803. }
  1804. createQueue();
  1805. }
  1806. }
  1807. }
  1808. catch(e){
  1809. isLinkRequestPending=false;
  1810. writeLog("",e);
  1811. return;
  1812. }
  1813. }
  1814. function verifyQueuePing(){
  1815. exitLinkRecovery();
  1816. if(lastEventTime<=linkRecoveryStart){
  1817. if(queue_request){
  1818. queue_request.abort();
  1819. queue_request=null;
  1820. isQueueRequestPending=false;
  1821. }
  1822. createQueue();
  1823. }
  1824. }
  1825. function getData(_b8){
  1826. if(_b8.firstChild){
  1827. return _b8.firstChild.data;
  1828. }else{
  1829. return "";
  1830. }
  1831. }
  1832. function getDataInt(_b9){
  1833. if(_b9.firstChild){
  1834. return parseInt(_b9.firstChild.data);
  1835. }else{
  1836. return -1;
  1837. }
  1838. }
  1839. function writeLog(msg,e){
  1840. if(!loggingEnabled){
  1841. return;
  1842. }
  1843. try{
  1844. if(e){
  1845. if(e.lineNumber){
  1846. msg+=": "+e.toString()+" at line "+e.lineNumber+" of "+e.fileName+"\nstack:\n"+e.stack;
  1847. }else{
  1848. msg+=": "+e.toString();
  1849. }
  1850. }
  1851. console.log(msg);
  1852. }
  1853. catch(loge){
  1854. }
  1855. }
  1856.  
  1857.